package com.bing.mapper;

import com.bing.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * Created by B-29931 on 9/19/2018.
 */
public interface UserMapper {

    @Insert("INSERT INTO user(name,age,password) VALUES(#{name},#{age},#{password})")
    void insert(User user);

    @Select("SELECT * FROM user WHERE id=#{id}")
    //mapper property to column if different
    @Results({@Result(property = "name", column = "name")})
    User getOne(int id);

    @Select("SELECT * FROM user")
    List<User> getAll();

    @Update("UPDATE user SET name=#{name},age=#{age},password=#{password} WHERE id=#{id}")
    void update(User user);

//    @Delete("DELETE FROM user WHERE id='${id}'")
    @Delete("DELETE FROM user WHERE id=#{id}")
    void delete(int id);
}
